package pa2.node;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Map;

import pa2.util.Callback;
import pa2.util.EqualityCompare;

public abstract class NodeDecorator<K extends EqualityCompare<K>, V, M extends Map<K,V>>
	extends UnicastRemoteObject implements Node<K, V, M> {
	
	protected Node<K,V,M> decoratedNode;
	
	protected NodeDecorator(Node<K,V,M> decoratedNode) throws RemoteException {
		this.decoratedNode = decoratedNode;
	}

	@Override
	public void put(K key, V value, Callback<K,V> callback)
			throws RemoteException {
		this.decoratedNode.put(key, value, callback);
	}

	@Override
	public void get(K key, Callback<K,V> callback) throws RemoteException {
		this.decoratedNode.get(key, callback);
	}

	@Override
	public void remove(K key, Callback<K,V> callback) throws RemoteException {
		this.decoratedNode.remove(key, callback);
	}

	@Override
	public K getKey() throws RemoteException {
		return this.decoratedNode.getKey();
	}
	
	@Override
	public NodeData<K, V, M> getData() throws RemoteException {
		return this.decoratedNode.getData();
	}

	@Override
	public void addChild(Node<K, V, M> child) throws RemoteException {
		this.decoratedNode.addChild(child);
	}

	@Override
	public void removeChild(Node<K, V, M> child) throws RemoteException {
		this.decoratedNode.removeChild(child);
	}
	
	@Override
	public Node<K, V, M> getLeftChild() throws RemoteException{
		return this.decoratedNode.getLeftChild();
	}
	
	@Override
	public Node<K, V, M> getRightChild() throws RemoteException{
		return this.decoratedNode.getRightChild();
	}

}
